﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="show.aspx.cs" Inherits="shopcart_show" %>

<%@ Register src="../UserControls/CFooterControl.ascx" tagname="CFooterControl" tagprefix="uc1" %>
<%@ Register src="../UserControls/CHeaderControl.ascx" tagname="CHeaderControl" tagprefix="uc2" %>
<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>

     <script type="text/javascript">

         function show(teamid, num, price, total, max) {
             var s = parseFloat(document.getElementById("sum").innerHTML);
             var n = parseInt(document.getElementById(num).value);
             var p = parseFloat(document.getElementById(price).innerHTML);
             n = isNaN(n) ? '' : n;
             document.getElementById(num).value = n;
             if (n <= 0) {
                 document.getElementById(num).value = 1;
                 n = 1;
             }

             if (max != 0) {
                 if (n > max) {
                     document.getElementById(num).value = max;
                     n = max;

                     alert("友情提示：你购买的数量已经超过库存");
                 }
             }

             var t = parseFloat(n * p);

             document.getElementById(total).innerHTML = t.toFixed(2);

             X.get(webroot + "ajax/car.aspx?proid=" + teamid + "&num=" + n);
             // alert(document.getElementById("farfee").innerHTML+"test");
             var f = document.getElementById("farfee").innerHTML;
             // toal();


         }

         function toal() {

             var t = document.getElementsByTagName("span")
             var fee = parseFloat(document.getElementById("farfee").innerHTML);
             //  alert(document.getElementById("farfee").innerHTML + "test");
             // alert(fee+"test1");
             var n = 0.0;
             for (var i = 0; i < t.length; i++) {
                 if (t[i].title == "total") {

                     //                     if (t[i].id == "total" + teamid) {
                     //                         alert("666");
                     //                     }
                     //                     if (t[i].id == "total"+teamid) {
                     //                         n += num;
                     //                     } else {
                     //                         n += parseFloat(t[i].innerHTML);
                     //                     }
                     n += parseFloat(t[i].innerHTML);
                 }
             }
             //  alert(fee+"tes1");

             document.getElementById("sum").innerHTML = parseFloat(n.toFixed(2)) + parseFloat(fee);


         }

         //         function delete_confirm(e) {
         //             if (event.srcElement.outerText == "删除")
         //                 event.returnValue = confirm("确认不购买此商品?");



         //         }
         //         document.onclick = delete_confirm;
    </script>
    <style type="text/css">
        .style1
        {
            width: 329px;
        }
    </style>
</head>

<body>
  
    <form id="form1" runat="server">

    <uc2:CHeaderControl ID="CHeaderControl1" runat="server" />
  <div id="header_container">
<div class="bdw" id="bdw">
<div class="cf" id="bd">
<div class="box-content">
  <table width="958" border="0" align="center" cellpadding="0" cellspacing="0"  style="padding-left: 10px; padding-right: 10px;" >
    <tr bgcolor="#FFFFFF">
      <td><table width="938px" border="0" align="center" cellpadding="0">
        <tr>
          <td><img src="../upfile/css/i/step1.png" /></td>
        </tr>
      </table>
        <table width="938px" border="0" align="center" cellpadding="0">
          <tr>
            <td style="border-bottom: 1px dashed rgb(174, 174, 174); "><span style="margin-bottom:10px"><span style="color:#f00">新功能！</span>使用购物车，您可以轻松一单购买多个团购。在每个页面点击购买按钮即可将商品加入购物车，统一结算。</span></td>
          </tr>
        </table>
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td>&nbsp;</td>
          </tr>
        </table>
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td>
    
                <input id="sumhid" type="hidden" />     

          <%if (carlist != null)
                {
                    decimal sum = 0;
                %>

             
            <table width="958" border="0" cellspacing="10" cellpadding="0" >
              <tr>
                <td colspan="2" align="center" bgcolor="#F2F2F2">项目</td>
                <td width="174" align="center" bgcolor="#F2F2F2">数量</td>
                <td width="27" align="center" bgcolor="#F2F2F2">&nbsp;</td>
                <td width="96" align="center" bgcolor="#F2F2F2">价格</td>
                <td width="29" align="center" bgcolor="#F2F2F2">&nbsp;</td>
                <td width="78" align="center" bgcolor="#F2F2F2">总价</td>
                <td width="47" align="center" bgcolor="#F2F2F2">操作</td>
              </tr>


                   <%foreach (Maticsoft.Model.Car model in carlist)
                {
                    if (teambll.GetModel(Convert.ToInt32(model.Qid)) != null)
                    {
                        if (teambll.GetModel(Convert.ToInt32(model.Qid)).Begin_time <= DateTime.Now && teambll.GetModel(Convert.ToInt32(model.Qid)).End_time >= DateTime.Now)
                        {
                            if (teambll.GetModel(Convert.ToInt32(model.Qid)).Delivery != "coupon" && teambll.GetModel(Convert.ToInt32(model.Qid)).Farefree != 0  && teambll.GetModel(Convert.ToInt32(model.Qid)).Team_type == "normal")
                            {
                                if (((teambll.GetModel(Convert.ToInt32(model.Qid)).Max_number > 0 && teambll.GetModel(Convert.ToInt32(model.Qid)).Now_number < teambll.GetModel(Convert.ToInt32(model.Qid)).Max_number) || (teambll.GetModel(Convert.ToInt32(model.Qid)).Max_number == 0)))
                                {
                                    sum += model.Price * model.Quantity; 
                    
                    %>
              <tr>
                <td width="132" align="center" bgcolor="#FFFFFF" style="padding:10px "><a href="../Team.aspx?id=<%=model.Qid %>" target=_blank><img src="<%=model.Pic %>" style="width:110px; height:70px; border:1px #aeaeae solid" /></a></td>
                <td width="307" bgcolor="#FFFFFF" style="padding:10px "><a href="../team.aspx?id=<%=model.Qid %>" target=_blank><%=teambll.GetModel(Convert.ToInt32(model.Qid))== null ? "" : teambll.GetModel(Convert.ToInt32(model.Qid)).Title%></a></td>
                <td align="center" bgcolor="#FFFFFF" style="padding:10px "><input type="text" id="num<%=model.Qid %>" onchange="show('<%=model.Qid %>','num<%=model.Qid %>','price<%=model.Qid %>','total<%=model.Qid %>','<%=model.Weight %>')" onkeyup="show('<%=model.Qid %>','num<%=model.Qid %>','price<%=model.Qid %>','total<%=model.Qid %>','<%=model.Weight %>')" class="input-text f-input deal-buy-quantity-input" maxlength="4" name="quantity-socking" value="<%=model.Quantity %>" alt="socking1027" category="product"/>
            <%-- <a class="deal-buy-update" href="javascript:void 0">更新数量</a>--%>
             
             </td>
                <td align="center" bgcolor="#FFFFFF" style="padding:10px ">x</td>
                <td align="center" bgcolor="#FFFFFF" style="padding:10px "><%=ASSystem.Currency %><span id="price<%=model.Qid %>"><%=model.Price %></span></td>
                <td align="center" bgcolor="#FFFFFF" style="padding:10px ">=</td>
                <td align="center" bgcolor="#FFFFFF" style="padding:10px "><%=ASSystem.Currency %><span id="total<%=model.Qid %>" title="total"><%=model.Price*model.Quantity %></span></td>
                <td align="center" bgcolor="#FFFFFF" style="padding:10px "><a href="../ajax/car.aspx?delid=<%=model.Qid %>" ask="确认不购买此商品?">删除</a></td>
              </tr>

               
              <%  }
                        }
                    }
                    }
                }%>


              <tr>
                <td colspan="2" bgcolor="#FFFFFF" style="padding:10px "><h1><span style="color:#f00; font-size:16px; padding-bottom:5px ">运费(本订单同时购买<%=farfee%>件或以上立刻包邮)</span></h1></td>
                <td bgcolor="#FFFFFF" style="padding:10px ">&nbsp;</td>
                <td bgcolor="#FFFFFF" style="padding:10px ">&nbsp;</td>
                <td bgcolor="#FFFFFF" style="padding:10px ">&nbsp;</td>
                <td bgcolor="#FFFFFF" style="padding:10px ">&nbsp;</td>
                <td bgcolor="#FFFFFF" style="padding:10px "><span style="color:#f00; font-size:16px; padding-bottom:5px "><%=ASSystem.Currency %><span id="farfee"><%=GetFarfee() %></span></span></td>
                <td bgcolor="#FFFFFF" style="padding:10px ">&nbsp;</td>
              </tr>
              <tr>
                <td colspan="2" bgcolor="#FFFFFF" style="padding:10px "><span style="color:#f00; font-size:16px; padding-bottom:5px ">应付总额</span></td>
                <td bgcolor="#FFFFFF" style="padding:10px ">&nbsp;</td>
                <td bgcolor="#FFFFFF" style="padding:10px ">&nbsp;</td>
                <td bgcolor="#FFFFFF" style="padding:10px ">&nbsp;</td>
                <td bgcolor="#FFFFFF" style="padding:10px ">=</td>
                <td bgcolor="#FFFFFF" style="padding:10px "><span style="color:#f00; font-size:16px; padding-bottom:5px "><%=ASSystem.Currency %><span id="sum">
                
             <%=sum+GetFarfee()%>
                </span></span></td>
                <td bgcolor="#FFFFFF" style="padding:10px ">&nbsp;</td>
              </tr>
              <tr>
                <td colspan="8" bgcolor="#FFFFFF" style="padding:10px ;border-bottom: 1px dashed rgb(174, 174, 174); ">
                  <input type="submit" class="formbutton" name="buy2" value="确认无误，去结算"/>
                  <a href="../index.aspx">继续挑选其他商品</a><a href</td>
                </tr>
            </table>
            

               <%}
                else
                { %>
                  <table width="958" border="0" cellspacing="10" cellpadding="0">
              <tr>
                <td>
                
                <a href="../Index.aspx"><img src="<%=ImagePath()%>empty_cart.png" width="442" height="173" /></a></td>
              </tr>
            </table>

               <% }%>
            
        



              <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr bgcolor="#FFFFFF">
                  <td>&nbsp;</td>
                </tr>
              </table>
              <table width="938px" border="0" align="center" cellpadding="0">
                <tr>
                  <td bgcolor="#FFFFFF" style="border-bottom: 1px dashed rgb(174, 174, 174); "><strong><span style="color:#f00; font-size:16px; padding-bottom:5px ">
                  
                  <%if (carlist != null)
                    {%>
                  今天还有这些团购(同时购买<%=farfee%>个就包邮)
                  <% }%>


                  
                  </span></strong></td>
                </tr>
              </table>
           <%--   <table width="958" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="980"><table width="958" border="0" cellspacing="1" cellpadding="0">
                    <tr>--%>
                    
                      <%foreach (Maticsoft.Model.Team teammodel in teamlist)
                  {
                            //if(teammodel.Delivery!="coupon"&&teammodel.Farefree!=0)
                            //{
                            //    if (teammodel.Max_number != 0 && teammodel.Now_number > teammodel.Max_number)
                            //    { 
                                
                            //    }else
                            //    {
                                    if (Utils.CookieCar.VerDictCarIsExit(teammodel.Id.ToString()) == false)
                                    {
                      %>
                   <div style="width:290px; float: left; padding: 10px; border-right-width: 1px; border-bottom-width: 1px; border-right-style: solid; border-bottom-style: solid; border-right-color: #CCCCCC; border-bottom-color: #CCCCCC;">
                <table border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td colspan="2" valign="top" ><div style="overflow:hidden; height: 55px;"><a href="../team.aspx?id=<%=teammodel.Id%>" target=_blank><%=teammodel.Title%></a></div></td>
                  </tr>
                  <tr>
                    <td width="134" valign="top" style="padding:10px "><span style="float:left"><a href="../team.aspx?id=<%=teammodel.Id %>" target="_blank"><img src="<%=teammodel.Image %>" style="border:1px #aeaeae solid;clear: none;" width="110" height="70" /></a></span></td>
                    <td width="156" valign="top">已有<span style="color:#f00; font-size:16px;"><%=teammodel.Now_number%></span>人购买<br />
                        <s>原价：<%=ASSystem.Currency%><%=teammodel.Market_price%></s><br />
                        <span style="color:#f00; font-size:16px;"><strong>现价：<%=ASSystem.Currency%><%=teammodel.Team_price%></strong></span></td>
                  </tr>
                  <tr>
                    <td colspan="2"><input type="button" value="放入购物车" class="formbutton" onclick="location.href='../ajax/car.aspx?id=<%=teammodel.Id%>'" /></td>
                  </tr>
                </table>
              </div>


              <%--    <div style="width:290px; float: left; padding: 10px; border-right-width: 1px; border-bottom-width: 1px; border-right-style: solid; border-bottom-style: solid; border-right-color: #CCCCCC; border-bottom-color: #CCCCCC;">
                <table border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td colspan="2" valign="top" ><div style="overflow:hidden; height: 55px;"><a href="../team.aspx?id=<%=teammodel.Id%>" target=_blank><%=teammodel.Title%></a></div></td>
                  </tr>
                  <tr>
                    <td width="134" valign="top" style="padding:10px "><span style="float:left"><a href="../team.aspx?id=<%=teammodel.Id %>" target="_blank"><img src="<%=teammodel.Image %>" style="width:110px; height:70x;border:1px #aeaeae solid" /></a></span></td>
                    <td width="156" valign="top">已有<span style="color:#f00; font-size:16px;">1279</span>人购买<br />
                        <s>原价：¥62.5</s><br />
                        <span style="color:#f00; font-size:16px;"><strong>现价：¥34.9</strong></span></td>
                  </tr>
                  <tr>
                    <td colspan="2"><input type="button" value="放入购物车" class="formbutton" onclick="location.href='../ajax/car.aspx?id=<%=teammodel.Id%>'" /></td>
                  </tr>
                </table>
              </div>--%>

                          <% }
                            //    }
                            //}
                  }%>
              
           

<%--                </td> 
          </tr>
        </table></td>
    </tr>
  </table>
  </div>
  </div>
  </div>
</div>--%>

                
              

           </td>
          </tr>
        </table></td>
    </tr>
  </table>
     <%=strpage %>
  </div>
  </div>
   


    <uc1:CFooterControl ID="CFooterControl1" runat="server" />
    





    </form>
</body>
</html>
